# vim: ft=python:
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from buildbot.changes.filter import ChangeFilter
from buildbot.scheduler import Dependent
from buildbot.scheduler import Nightly
from buildbot.scheduler import Periodic
from buildbot.scheduler import Scheduler
from buildbot.scheduler import Triggerable
from buildbot.status.mail import MailNotifier

from common import chromium_utils

# These modules come from scripts/master, which must be in the PYTHONPATH.
from master import build_utils
from master import chromium_notifier
from master import failures_notifier
from master import master_config
from master import master_utils
from master import slaves_list
from master import gitiles_poller

from master.factory import annotator_factory
from master.factory import chromium_factory

# These modules come from scripts/common, which must be in the PYTHONPATH.
import config
import master_site_config

import master_win_drmemory_cfg

ActiveMaster = master_site_config.ChromiumFYI

DRMEMORY_NOTIFIER = True
STATUS_PUSH = False

# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}
c['status'] = []

config.DatabaseSetup(c, require_dbconfig=ActiveMaster.is_production_host)

####### CHANGESOURCES

# Polls config.Master.trunk_url for changes
chromium_repo_url = config.Master.git_server_url + '/chromium/src'
trunk_poller = gitiles_poller.GitilesPoller(chromium_repo_url,
                                            project='chromium')

c['change_source'] = [trunk_poller]

# Polls the blink merging practice repo.
chromium_practice_repo_url = \
  config.Master.git_server_url + '/playground/chromium-blink-merge'
practice_poller = gitiles_poller.GitilesPoller(chromium_practice_repo_url,
                                               project='chromium-playground')
c['change_source'].append(practice_poller)
s_practice = Scheduler(
    name='chromium-practice',
    treeStableTimer=60,
    change_filter=ChangeFilter(project='chromium-playground', branch='master'),
    builderNames=['ChromiumPractice',
                  ])
s_practice_builder = Triggerable(
    name='cr_practice', builderNames=['ChromiumPracticeTester'])


# Number of machines to shard ash browser_tests over.
ASH_SHARDS = 2

####### SCHEDULERS

## configure the Schedulers

# Main scheduler for all changes in trunk.
s_chromium = Scheduler(
    name='chromium',
    treeStableTimer=60,
    change_filter=ChangeFilter(project='chromium', branch='master'),
    builderNames=['Chromium Builder',
                  'Chromium Windows Analyze',
                  'Chromium Windows Instant Extended',
                  'Chromium Linux Buildrunner',
                  'Chromium Windows Buildrunner',
                  'Chromium Mac Buildrunner',
                  'Chromium Mac 10.8 Buildrunner',
                  'Chromium Mac 10.9 Buildrunner',
                  'Chromium Builder (dbg)',
                  # The bots need a short name to work around crbug.com/399990.
                  'Cr Win VS2013 (dbg)',
                  'Cr Win VS2013',
                  'CrWinGoma',
                  'CrWinGoma(dll)',  # not (shared) cause crbug.com/399990
                  'CrWin7Goma',
                  'CrWin7Goma(dll)',  # not (shared) cause crbug.com/399990
                  'CrWin7Goma(dbg)',
                  'CrWin7Goma(clbr)',  # not (clobber) cause crbug.com/399990
                  'CrWinClangGoma',
                  'CrWinClang',
                  'CrWinClang(dbg)',
                  'CrWinClang(shared)',
                  'CrWinClang64',
                  'CrWinClang64(dbg)',
                  'CrWinClang64(dll)',  # not (shared) cause crbug.com/399990
                  'CrWinClangLLD',
                  'CrWinAsan',
                  'ClangToTLinux',
                  'ClangToTLinux (dbg)',
                  'ClangToTLinuxASan',
                  'ClangToTAndroidASan',
                  'ClangToTMac',
                  'ClangToTMac (dbg)',
                  'ClangToTMacASan',
                  'ClangToTiOS',
                  'ClangToTWin',
                  'ClangToTWin(dbg)',
                  'ClangToTWin(dll)',  # not (shared) cause crbug.com/399990
                  'ClangToTWin64',
                  'ClangToTWin64(dbg)',
                  'ClangToTWin64(dll)',  # not (shared) cause crbug.com/399990
                  'CrWinAsan(dll)',  # not (asan/shared) cause crbug.com/399990
                  'Chromium Win x64 Clobber',
                  'Chromium Win PGO Builder',
                  'Chromium Win x64 PGO Builder',
                  'Blink Linux LSan ASan',
                  'Windows Builder (DrMemory)',
                  'Windows Builder (DrMemory x64)',
                  'Android Builder (dbg)',
                  'Android MIPS Builder (dbg)',
                  'Android x86 Builder (dbg)',
                  'Android User Builder Tests',
                  'Android Asan Builder Tests (dbg)',
                  'Android Builder Tests (JB Nexus7)(shared)',
                  'Android AOSP Builder (dbg)',
                  'Android x64 Builder (dbg)',
                  'Android Cronet Builder',
                  'Android Remoting Tests',
                  'Chromium_iOS_Simulator_(dbg)',
                  'Chromium_iOS_Device',
                  'Chromium_iOS_Device_(ninja)',
                  'More NaCl Tests (mac)',
                  'More NaCl Tests (linux)',
                  'Chromium Linux Goma Canary',
                  'Chromium Linux Goma Canary (clobber)',
                  'Chromium Linux Precise Goma LinkTest',
                  'Chromium Linux32 Goma Canary (clobber)',
                  'Chromium Mac 10.6 Goma Canary',
                  'Chromium Mac 10.7 Goma Canary',
                  'Chromium Mac 10.6 Goma Canary (clobber)',
                  'Chromium Mac 10.7 Goma Canary (clobber)',
                  'Chromium Mac 10.10',
                  'Windows 8 App Certification',
                  'ChromiumOS Linux Tests',
                  'Ozone ECS Linux',
                  'Linux ARM',
                  'Linux ARM Cross-Compile',
                  'Linux Trusty',
                  'Linux Trusty (32)',
                  'Linux Trusty (dbg)',
                  'Linux Trusty (dbg)(32)',
                  'Print Preview Linux',
                  'Print Preview Mac',
                  'Print Preview Win',
                  'Site Isolation Linux',
                  'Site Isolation Win',
                  'Browser Side Navigation Linux',
                  'Closure Compilation Linux',
                  'CFI Linux',
                  ])

# Triggerable scheduler for Windows Release.
s_chromium_win_rel = Triggerable(
    name='win_rel',
    builderNames=['Chromium Win MiniInstaller Tests',
                  'More NaCl Tests (win32)',
                  'More NaCl Tests (win64)',
                  'Win8 Tests (1)',
                  'Win8 Tests (2)',])

# Triggerable scheduler for Windows Debug.
s_chromium_win_dbg = Triggerable(
    name='win_dbg',
    builderNames=['Vista Tests (dbg)(1)',
                  'Vista Tests (dbg)(2)',])

# Triggerable scheduler for Android Builder
s_chromium_android_dbg = Triggerable(
    name='android_dbg',
    builderNames=['Android Tests (JB GalaxyNexus)(dbg)',
                  'Android Tests (JB Nexus7)(dbg)',
                  'Android Tests (L Nexus5)(dbg)',
                  'Android ChromeDriver Tests (dbg)',
                  'Android Tests (trial)(dbg)',
                  'Android Tests (amp)(dbg)'])

# Triggerable scheduler for Cronet Builder
s_chromium_cronet_rel = Triggerable(
    name='cronet_rel',
    builderNames=['Android Cronet ARMv6 Builder',
                  'Android Cronet ARM64 Builder',
                  'Android Cronet x86 Builder',
                  'Android Cronet MIPS Builder',
                  'Android Cronet Builder (dbg)',
                  'Android Cronet ARM64 Builder (dbg)',
                  'Android Cronet x86 Builder (dbg)'])

# Windows Dr. Memory build-bot list
t_drmemory_bots=[
  'Windows Tests (DrMemory XP)',
  'Windows Tests (DrMemory)',
  ]

# Windows Browser (DrMemory light)
WINDOWS_BROWSER_DRMEMORY_LIGHT_TESTERS = 2
for i in range(WINDOWS_BROWSER_DRMEMORY_LIGHT_TESTERS):
    t_drmemory_bots.append('Windows Browser (DrMemory light) (%d)' % (i+1))

s_chromium_windows_drmemory_trigger = Triggerable(
    name='chromium_windows_drmemory',
    builderNames=t_drmemory_bots)

# Windows Dr. Memory x64 build-bot list
t_drmemory_64_bots=[
  'Windows Tests (DrMemory x64)',
  ]

s_chromium_windows_drmemory_64_trigger = Triggerable(
    name='chromium_windows_drmemory_64',
    builderNames=t_drmemory_64_bots)

# Triggerable scheduler for Linux ARM
s_chromium_linux_arm = Triggerable(
    name='chromium_linux_arm',
    builderNames=[
        'Linux ARM Tests (Panda)'
    ])

# Triggerable schedulers for clang/win bots
s_win_clang = Triggerable(
    name='cr_win_clang', builderNames=['CrWinClang tester'])
s_win_clang_dbg = Triggerable(
    name='cr_win_clang_dbg', builderNames=['CrWinClang(dbg) tester'])
s_win_clang_shared = Triggerable(
    name='cr_win_clang_shared', builderNames=['CrWinClang(shared) tester'])
s_win_clang_64 = Triggerable(
    name='cr_win_clang_64',
    builderNames=['CrWinClang64 tester'])
s_win_clang_64_dbg = Triggerable(
    name='cr_win_clang_64_dbg',
    builderNames=['CrWinClang64(dbg) tester'])
s_win_clang_64_shared = Triggerable(
    name='cr_win_clang_64_shared',
    builderNames=['CrWinClang64(dll) tester'])
s_win_clang_lld = Triggerable(
    name='cr_win_clang_lld', builderNames=['CrWinClangLLD tester'])
s_win_clang_asan = Triggerable(
    name='cr_win_clang_asan', builderNames=['CrWinAsan tester'])
s_win_clang_asan_shared = Triggerable(
    name='cr_win_clang_asan_shared', builderNames=['CrWinAsan(dll) tester'])

# Triggerable schedulers for Clang ToT bots.
s_clang_tot_linux = Triggerable(
    name='clang_tot_linux', builderNames=['ClangToTLinux tester'])
s_clang_tot_linux_asan = Triggerable(
    name='clang_tot_linux_asan', builderNames=['ClangToTLinuxASan tester'])
s_clang_tot_mac = Triggerable(
    name='clang_tot_mac', builderNames=['ClangToTMac tester'])
s_clang_tot_mac_asan = Triggerable(
    name='clang_tot_mac_asan', builderNames=['ClangToTMacASan tester'])
s_clang_tot_win = Triggerable(
    name='clang_tot_win', builderNames=['ClangToTWin tester'])
s_clang_tot_win_dbg = Triggerable(
    name='clang_tot_win_dbg', builderNames=['ClangToTWin(dbg) tester'])
s_clang_tot_win_dll = Triggerable(
    name='clang_tot_win_dll', builderNames=['ClangToTWin(dll) tester'])
s_clang_tot_win64 = Triggerable(
    name='clang_tot_win64', builderNames=['ClangToTWin64 tester'])
s_clang_tot_win64_dbg = Triggerable(
    name='clang_tot_win64_dbg', builderNames=['ClangToTWin64(dbg) tester'])
s_clang_tot_win64_dll = Triggerable(
    name='clang_tot_win64_dll', builderNames=['ClangToTWin64(dll) tester'])

c['schedulers'] = [s_chromium,
                   s_chromium_android_dbg,
                   s_chromium_cronet_rel,
                   s_chromium_win_rel,
                   s_chromium_win_dbg,
                   s_chromium_windows_drmemory_trigger,
                   s_chromium_windows_drmemory_64_trigger,
                   s_chromium_linux_arm,
                   s_win_clang,
                   s_win_clang_dbg,
                   s_win_clang_shared,
                   s_win_clang_64,
                   s_win_clang_64_dbg,
                   s_win_clang_64_shared,
                   s_win_clang_lld,
                   s_win_clang_asan,
                   s_win_clang_asan_shared,
                   s_practice,
                   s_practice_builder,
                   s_clang_tot_linux,
                   s_clang_tot_linux_asan,
                   s_clang_tot_mac,
                   s_clang_tot_mac_asan,
                   s_clang_tot_win,
                   s_clang_tot_win_dbg,
                   s_clang_tot_win_dll,
                   s_clang_tot_win64,
                   s_clang_tot_win64_dbg,
                   s_clang_tot_win64_dll,
]

####### BUILDERS

# buildbot/process/factory.py provides several BuildFactory classes you can
# start with, which implement build processes for common targets (GNU
# autoconf projects, CPAN perl modules, etc). The factory.BuildFactory is the
# base class, and is configured with a series of BuildSteps. When the build
# is run, the appropriate buildslave is told to execute each Step in turn.

# the first BuildStep is typically responsible for obtaining a copy of the
# sources. There are source-obtaining Steps in buildbot/process/step.py for
# CVS, SVN, and others.

builders = []

# ----------------------------------------------------------------------------
# FACTORIES

F = chromium_factory.ChromiumFactory
def win(): return F('src/chrome', 'win32')
def win_build(): return F('src/build', 'win32')
def win_out(): return F('src/out', 'win32')
def mac(): return F('src/xcodebuild', 'darwin')
def linux(**kwargs): return F('src/out', 'linux2', **kwargs)
def ios(): return F('src/xcodebuild', 'darwin')

def chromeos():
  return F('src/build', 'linux2')

def linux_android(custom_deps_list=None):
  return F('src/build', 'linux2', nohooks_on_update=True, target_os='android',
           custom_deps_list=custom_deps_list)

chromium_rel_archive = master_config.GetGSUtilUrl(
    'chromium-build-transfer', 'Chromium FYI Builder')

chromium_dbg_archive = master_config.GetGSUtilUrl(
    'chromium-build-transfer', 'Chromium FYI Builder (dbg)')

chromium_windows_drmemory_archive = master_config.GetGSUtilUrl(
    'chromium-build-transfer', 'drm-cr')

chromium_windows_drmemory_64_archive = master_config.GetGSUtilUrl(
    'chromium-build-transfer', 'drm-cr-64')

chromium_android_fyi_dbg_archive = master_config.GetGSUtilUrl(
    'chromium-fyi-archive', 'chromium.fyi/Android Builder (dbg)')

# The identifier of the factory is the build configuration. If two factories
# are using the same build configuration, they should have the same identifier.
f_chromium_rel_builder = win_build().ChromiumFactory(
    slave_type='Builder',
    build_url=chromium_rel_archive,
    project='all.sln;chromium_builder_tests',
    factory_properties={'trigger': 'win_rel',
                        'gclient_env': {
                          'GYP_DEFINES': 'fastbuild=1',
                          'GYP_MSVS_VERSION': '2015',
                        }})

f_chromium_dbg_builder = win_build().ChromiumFactory(
    slave_type='Builder',
    build_url=chromium_dbg_archive,
    target='Debug',
    project='all.sln;chromium_builder_tests',
    factory_properties={'trigger': 'win_dbg',
                        'gclient_env': {
                          'GYP_DEFINES': 'fastbuild=1',
                          'GYP_MSVS_VERSION': '2015',
                        }})

f_chromium_win_pgo_builder = \
    annotator_factory.AnnotatorFactory().BaseFactory(recipe='chromium_pgo',
                                                     timeout=24000)

f_chromium_win_x64_pgo_builder = \
    annotator_factory.AnnotatorFactory().BaseFactory(recipe='chromium_pgo',
                                                     timeout=24000)

f_win_analyze = \
  annotator_factory.AnnotatorFactory().BaseFactory(
    recipe='win_analyze')

f_win_instantextended = win_build().ChromiumFactory(
           project='all.sln;chromium_builder_tests',
           tests=[
               'instant_extended_manual_tests',
               'buildrunner_tests',
           ],
           slave_type='BuilderTester',
           factory_properties={
               'gclient_env': {
                   'GYP_DEFINES': 'fastbuild=1',
               },
               'process_dumps': True,
               'start_crash_handler': True,
               'generate_gtest_json': True,
           })

f_linux_buildrunner = linux().ChromiumFactory(
           tests=['base_unittests_br',
                  'browser_tests_br',
                  'cacheinvalidation_br',
                  'content_browsertests_br',
                  'crypto_br',
                  'dbus_br',
                  'display_unittests_br',
                  'gfx_unittests_br',
                  'gpu_br',
                  'jingle_br',
                  'media_br',
                  'net_br',
                  'ppapi_unittests_br',
                  'printing_br',
                  'remoting_br',
                  'unit_br',
                  'url_unittests_br',
                  'buildrunner_tests',
           ],
           options=['--compiler=goma'],
           slave_type='Builder',
           factory_properties={
               'archive_build': False,
               'generate_gtest_json': True,
               'gclient_env': {
                   'GYP_DEFINES': 'target_arch=x64 '
                   'tests_run=noop,component=shared_library'}
           })

f_win_buildrunner = win_build().ChromiumFactory(
           project='all.sln;chromium_builder_tests',
           tests=['base_unittests_br',
                  'browser_tests_br',
                  'cacheinvalidation_br',
                  'content_browsertests_br',
                  'courgette_br',
                  'crypto_br',
                  'gfx_unittests_br',
                  'gpu_br',
                  'installer_br',
                  'jingle_br',
                  'media_br',
                  'ppapi_unittests_br',
                  'printing_br',
                  'remoting_br',
                  'sandbox_br',
                  'url_unittests_br',
                  'buildrunner_tests',
           ],
           slave_type='Builder',
           factory_properties={'gclient_env': {'GYP_DEFINES': 'fastbuild=1'},
                               'process_dumps': True,
                               'start_crash_handler': True,
                               'generate_gtest_json': True,
                               'archive_build': False,
           })

f_mac_buildrunner = mac().ChromiumFactory(
           tests=['base_unittests_br',
                  'browser_tests_br',
                  'cacheinvalidation_br',
                  'content_browsertests_br',
                  'crypto_br',
                  'url_unittests_br',
                  'gpu_br',
                  'jingle_br',
                  'media_br',
                  'message_center_unittests_br',
                  'ppapi_unittests_br',
                  'printing_br',
                  'remoting_br',
                  'buildrunner_tests',
           ],
           options=['--compiler=goma-clang', '--', '-target',
                    'chromium_builder_tests'],
           factory_properties={
               'archive_build': False,
               'generate_gtest_json': True
           })


def without(these, notthese):
  return [x for x in these if x not in notthese]

tests_win_1 = ['base_unittests',
               'cacheinvalidation_unittests',
               'chrome_elf_unittests',
               'components_unittests',
               'courgette_unittests',
               'crypto_unittests',
               'device_unittests',
               'extensions_unittests',
               'gcm_unit_tests',
               'google_apis_unittests',
               'gpu',
               'installer',
               'jingle',
               'media',
               'net',
               'ppapi_unittests',
               'printing',
               'remoting',
               'sandbox',
               'unit',
               'url_unittests',
]
tests_win_2 = ['browser_tests',
               'content_browsertests']

f_chromium_dbg_tests_1 = win_build().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_dbg_archive,
    tests=tests_win_1,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_dbg_tests_2 = win_build().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_dbg_archive,
    tests=tests_win_2,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_rel_tests_1 = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=tests_win_1,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_rel_tests_2 = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=tests_win_2,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_cr_win_rel_mini_installer = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['test_installer'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True,})

f_chromium_rel_win_morenacl = win().ChromiumFactory(
    target='Release',
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['nacl_integration'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_rel_mac_morenacl = mac().ChromiumFactory(
    target='Release',
    tests=['nacl_integration'],
    options=['--compiler=goma-clang'])

f_chromium_rel_linux_morenacl = linux().ChromiumFactory(
    target='Release',
    tests=['nacl_integration'])

f_blink_linux_lsan_asan = linux().ChromiumFactory(
    tests=['webkit'],
    options=[
        '--build-tool=ninja',
        '--compiler=goma-clang',
        '--',
        'blink_tests'
    ],
    factory_properties={
        'additional_expectations': [
            ['third_party', 'WebKit', 'LayoutTests', 'ASANExpectations' ],
        ],
        'archive_webkit_results': False,
        'asan': True,
        'blink_config': 'blink',
        'gclient_env': {
          'GYP_DEFINES': 'asan=1 lsan=1',
          'GYP_GENERATORS': 'ninja',
        },
        'generate_gtest_json': True,
        'lsan': True,
        'time_out_ms': '48000',
        'webkit_test_options': ['--enable-sanitizer'],
    }
)

# DrMemory Builder
f_chromium_windows_drmemory_builder = win_out().ChromiumFactory(
    target='Release',
    slave_type='Builder',
    # TODO(bruening): remove "_dbg" from this name in all.gyp as it is
    # not limited to just Debug.
    options=['--build-tool=ninja', '--', 'chromium_builder_dbg_drmemory_win'],
    factory_properties={
      'gclient_env': { 'GYP_DEFINES' : ('build_for_tool=drmemory '
                                        'component=shared_library'),
                     },
      'package_pdb_files': True,
      'trigger': 'chromium_windows_drmemory',
      'build_url': chromium_windows_drmemory_archive,
    }
)

# DrMemory x64 Builder
f_chromium_windows_drmemory_64_builder = win_out().ChromiumFactory(
    target='Release_x64',
    slave_type='Builder',
    # TODO(bruening): remove "_dbg" from this name in all.gyp as it is
    # not limited to just Debug.
    options=['--build-tool=ninja', '--', 'chromium_builder_dbg_drmemory_win'],
    factory_properties={
      'gclient_env': {
        'GYP_DEFINES' : (
            'build_for_tool=drmemory component=shared_library '
            'target_arch=x64'),
      },
      'package_pdb_files': True,
      'trigger': 'chromium_windows_drmemory',
      'build_url': chromium_windows_drmemory_64_archive,
    }
)

# Windows Tests (DrMemory XP)
f_chromium_rel_win_drmemory = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Release',
    build_url=chromium_windows_drmemory_archive,
    tests=[
      'drmemory_light_url',
      'drmemory_light_printing',
      'drmemory_light_media',
      'drmemory_light_sql',
      'drmemory_light_crypto',
      'drmemory_light_remoting',
      'drmemory_light_ipc_tests',
      'drmemory_light_base_unittests',
      'drmemory_light_net',
      # run tests in shards to decrease the number of reports per shard.
      'drmemory_light_unit_1_of_3',
      'drmemory_light_unit_2_of_3',
      'drmemory_light_unit_3_of_3',
    ],
    factory_properties={'halt_on_missing_build': True}
)

# Windows Tests (DrMemory)
f_chromium_rel_win_tests_drmemory = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Release',
    build_url=chromium_windows_drmemory_archive,
    tests=[
      'drmemory_light_webkit',
      'drmemory_full_webkit',
    ],
    factory_properties={'halt_on_missing_build': True}
)

# Windows Tests (DrMemory x64)
f_chromium_rel_win_tests_drmemory_64 = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Release',
    build_url=chromium_windows_drmemory_64_archive,
    tests=[
      'drmemory_light_url',
      'drmemory_light_printing',
      'drmemory_light_media',
    ],
    factory_properties={'halt_on_missing_build': True}
)

win_x64_tests = [
  'base_unittests',
  'cacheinvalidation_unittests',
  'cc_unittests',
  'chromedriver_unittests',
  'components_unittests',
  'content_browsertests',
  'courgette_unittests',
  'crypto_unittests',
  'gcm_unit_tests',
  'gpu',
  'installer',
  'interactive_ui_tests',
  'jingle',
  'media',
  'nacl_integration',
  'net',
  'ppapi_unittests',
  'printing',
  'remoting',
  'sandbox',
  'unit',
  'url_unittests',

  # These are long, so do them last
  'browser_tests',
  'sync_integration',
]

f_chromium_win_x64 = win_out().ChromiumFactory(
    slave_type='BuilderTester',
    clobber=True,
    target='Release_x64',
    tests=win_x64_tests,
    options=['--build-tool=ninja', '--', 'chromium_builder_tests'],
    factory_properties={
      'gclient_env': {
        'GYP_DEFINES': 'target_arch=x64',
    }})

f_chromium_win_shared_2013_dbg = win_out().ChromiumFactory(
    slave_type='BuilderTester',
    options=['chromium_builder_tests'],
    tests=tests_win_1,
    target='Debug',
    factory_properties={
        'gclient_env': {
          'GYP_DEFINES': 'component=shared_library fastbuild=1',
    }})

f_chromium_win_shared_2013 = win_out().ChromiumFactory(
    slave_type='BuilderTester',
    options=['chromium_builder_tests'],
    tests=tests_win_1,
    target='Release',
    factory_properties={
        'gclient_env': {
          'GYP_DEFINES': 'component=shared_library fastbuild=1',
    }})

f_chromium_dbg_android_mips_builder = \
  annotator_factory.AnnotatorFactory().BaseFactory(
    recipe='android/builder')

f_chromium_dbg_android_x86_builder = \
  linux_android().ChromiumAnnotationFactory(
    target='Debug',
    slave_type='AnnotatedBuilder',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'fyi-x86-builder-dbg',
    })


f_chromium_rel_android_builder_tests = \
  linux_android().ChromiumAnnotationFactory(
    target='Release',
    slave_type='AnnotatedBuilder',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'fyi-user-builder-unit-tests-rel',
    })


f_chromium_dbg_android_shared = \
  linux_android().ChromiumAnnotationFactory(
    target='Debug',
    slave_type='AnnotatedBuilder',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'fyi-component-builder-tests-dbg',
    })


def f_chromium_dbg_android_tests(bot_id_suffix):
  return linux_android().ChromiumAnnotationFactory(
    target='Debug',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'fyi-tests-dbg-%s' % bot_id_suffix,
      'build_url': chromium_android_fyi_dbg_archive,
      'gclient_timeout': 3600
    })

def f_chromium_dbg_android_tests_user_build(bot_id_suffix):
  return linux_android().ChromiumAnnotationFactory(
    target='Debug',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'user-build-fyi-tests-dbg-%s' % bot_id_suffix,
      'build_url': chromium_android_fyi_dbg_archive,
      'gclient_timeout': 3600
    })

f_chromium_dbg_android_chromedriver_tests = \
  linux_android(
      custom_deps_list=[F.CUSTOM_DEPS_WEBDRIVER_JAVA_TESTS]
      ).ChromiumAnnotationFactory(
    target='Debug',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'chromedriver-fyi-tests-dbg',
      'build_url': chromium_android_fyi_dbg_archive,
    })


f_chromium_dbg_android_asan_builder_tests = \
  linux_android().ChromiumAnnotationFactory(
    target='Debug',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'asan-builder-tests-dbg',
    })

f_chromium_dbg_android_aosp_builder = \
  annotator_factory.AnnotatorFactory().BaseFactory(
    recipe='android_webview_aosp')

f_chromium_mac_1010 = annotator_factory.AnnotatorFactory().BaseFactory(
  'chromium')

f_windows_8_app_certification = win().ChromiumFactory(
    tests=[],
    options=[],
    factory_properties={})


f_chromiumos_linux_tests = linux().ChromiumFactory(
    slave_type='BuilderTester',
    target='Debug',
    tests=['sync_integration'],
    factory_properties={
      'test_results_server': 'test-results.appspot.com',
      'generate_gtest_json': True,
    })

# ----------------------------------------------------------------------------
# BUILDER DEFINITIONS

# The 'builders' list defines the Builders. Each one is configured with a
# dictionary, using the following keys:
#  name (required): the name used to describe this bilder
#  slavename (required): which slave to use, must appear in c['slaves']
#  builddir (optional): which subdirectory to run the builder in
#  factory (required): a BuildFactory to define how the build is run
#  periodicBuildTime (optional): if set, force a build every N seconds
#  category (optional): it is not used in the normal 'buildbot' meaning. It is
#                       used by gatekeeper to determine which steps it should
#                       look for to close the tree.
#

m_annotator = annotator_factory.AnnotatorFactory()

b_linux_practice = {
  'name': 'ChromiumPractice',
  'builddir': 'chromiumpractice',
  'factory': m_annotator.BaseFactory('chromium', triggers=['cr_practice']),
  'category': 'githack',
  'auto_reboot': False,
}
b_linux_practice_tester = {
  'name': 'ChromiumPracticeTester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'githack',
  'auto_reboot': False,
}

b_chromium_win_analyze = {'name': 'Chromium Windows Analyze',
  'builddir': 'Chromium_Windows_Analyze',
  'factory': f_win_analyze,
  'auto_reboot': False,
}

b_chromium_win_instantextended = {'name': 'Chromium Windows Instant Extended',
  'builddir': 'Chromium_Windows_Instant_Extended',
  'factory': f_win_instantextended,
  'auto_reboot': False,
}

b_chromium_lin_buildrunner = {'name': 'Chromium Linux Buildrunner',
  'builddir': 'Chromium_Linux_Buildrunner',
  'factory': f_linux_buildrunner,
  'auto_reboot': False,
}

b_chromium_win_buildrunner = {'name': 'Chromium Windows Buildrunner',
  'builddir': 'Chromium_Windows_Buildrunner',
  'factory': f_win_buildrunner,
  'auto_reboot': False,
}

b_chromium_mac_buildrunner = {'name': 'Chromium Mac Buildrunner',
  'builddir': 'Chromium_Mac_Buildrunner',
  'factory': f_mac_buildrunner,
  'slavebuilddir': 'mac_buildrunner_slave',
  'auto_reboot': False,
}

b_chromium_mac_10_8_buildrunner = {'name': 'Chromium Mac 10.8 Buildrunner',
  'builddir': 'Chromium_Mac_10_8_Buildrunner',
  'factory': f_mac_buildrunner,
  'auto_reboot': False,
}

b_chromium_mac_10_9_buildrunner = {'name': 'Chromium Mac 10.9 Buildrunner',
  'builddir': 'Chromium_Mac_10_9_Buildrunner',
  'factory': f_mac_buildrunner,
  'auto_reboot': False,
}

b_chromium_rel_builder = {'name': 'Chromium Builder',
  'builddir': 'chromium-rel-builder',
  'factory': f_chromium_rel_builder,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_dbg_builder = {'name': 'Chromium Builder (dbg)',
  'builddir': 'chromium-dbg-builder',
  'factory': f_chromium_dbg_builder,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_win_pgo_builder = {
  'name': 'Chromium Win PGO Builder',
  'builddir': 'chromium-win-pgo-builder',
  'factory': f_chromium_win_pgo_builder,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_win_x64_pgo_builder = {
  'name': 'Chromium Win x64 PGO Builder',
  'builddir': 'chromium-win-x64-pgo-builder',
  'factory': f_chromium_win_x64_pgo_builder,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_dbg_vista_tests_1 = {
  'name': 'Vista Tests (dbg)(1)',
  'factory': f_chromium_dbg_tests_1,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_dbg_vista_tests_2 = {
  'name': 'Vista Tests (dbg)(2)',
  'factory': f_chromium_dbg_tests_2,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_rel_win8_tests_1 = {
  'name': 'Win8 Tests (1)',
  'factory': f_chromium_rel_tests_1,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_rel_win8_tests_2 = {
  'name': 'Win8 Tests (2)',
  'factory': f_chromium_rel_tests_2,
  'category': 'windows',
  'auto_reboot': False,
}

b_blink_linux_lsan_asan = {
  'name': 'Blink Linux LSan ASan',
  'builddir': 'blink-linux-lsan-asan',
  'factory': f_blink_linux_lsan_asan,
  'category': 'Sanitizers',
  'auto_reboot': True,
}

b_chromium_rel_win32_morenacl = {
  'name': 'More NaCl Tests (win32)',
  'builddir': 'chromium-rel-win32-morenacl',
  'factory': f_chromium_rel_win_morenacl,
  'category': 'morenacl',
  'auto_reboot': False,
}

b_chromium_rel_win64_morenacl = {
  'name': 'More NaCl Tests (win64)',
  'builddir': 'chromium-rel-win64-morenacl',
  'factory': f_chromium_rel_win_morenacl,
  'category': 'morenacl',
  'auto_reboot': False,
}

b_chromium_rel_mac_morenacl = {
  'name': 'More NaCl Tests (mac)',
  'builddir': 'chromium-rel-mac-morenacl',
  'factory': f_chromium_rel_mac_morenacl,
  'category': 'morenacl',
  'auto_reboot': False,
}

b_chromium_rel_linux_morenacl = {
  'name': 'More NaCl Tests (linux)',
  'builddir': 'chromium-rel-linux-morenacl',
  'factory': f_chromium_rel_linux_morenacl,
  'category': 'morenacl',
  'auto_reboot': False,
}

b_chromium_win_goma = {
  'name': 'CrWinGoma',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_win_goma_shared = {
  'name': 'CrWinGoma(dll)',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_win7_goma = {
  'name': 'CrWin7Goma',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_win7_goma_shared = {
  'name': 'CrWin7Goma(dll)',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_win7_goma_dbg = {
  'name': 'CrWin7Goma(dbg)',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_win7_goma_clobber = {
  'name': 'CrWin7Goma(clbr)',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_win_clang_goma = {
  'name': 'CrWinClangGoma',
  'factory': m_annotator.BaseFactory('chromium', timeout=3000),
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_win_x64 = {
  'name': 'Chromium Win x64 Clobber',
  'factory': f_chromium_win_x64,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_win_clang = {
  'name': 'CrWinClang',
  'factory': m_annotator.BaseFactory('chromium', triggers=['cr_win_clang']),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_tester = {
  'name': 'CrWinClang tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_dbg = {
  'name': 'CrWinClang(dbg)',
  'factory': m_annotator.BaseFactory('chromium', triggers=['cr_win_clang_dbg']),
  'category': 'win clang',
  'auto_reboot': False,
}
b_chromium_win_clang_dbg_tester = {
  'name': 'CrWinClang(dbg) tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_shared = {
  'name': 'CrWinClang(shared)',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['cr_win_clang_shared']),
  'category': 'win clang',
  'auto_reboot': False,
}
b_chromium_win_clang_shared_tester = {
  'name': 'CrWinClang(shared) tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_64 = {
  'name': 'CrWinClang64',
  'factory': m_annotator.BaseFactory('chromium', triggers=['cr_win_clang_64']),
  'category': 'win clang',
  'auto_reboot': False,
}
b_chromium_win_clang_64_tester = {
  'name': 'CrWinClang64 tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_64_dbg = {
  'name': 'CrWinClang64(dbg)',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['cr_win_clang_64_dbg']),
  'category': 'win clang',
  'auto_reboot': False,
}
b_chromium_win_clang_64_dbg_tester = {
  'name': 'CrWinClang64(dbg) tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_64_shared = {
  'name': 'CrWinClang64(dll)',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['cr_win_clang_64_shared']),
  'category': 'win clang',
  'auto_reboot': False,
}
b_chromium_win_clang_64_shared_tester = {
  'name': 'CrWinClang64(dll) tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'win clang',
  'auto_reboot': False,
}

b_chromium_win_clang_lld = {
  'name': 'CrWinClangLLD',
  'factory': m_annotator.BaseFactory('chromium', triggers=['cr_win_clang_lld']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_chromium_win_clang_lld_tester = {
  'name': 'CrWinClangLLD tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_chromium_win_clang_asan = {
  'name': 'CrWinAsan',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['cr_win_clang_asan']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_chromium_win_clang_asan_tester = {
  'name': 'CrWinAsan tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_chromium_win_clang_asan_shared = {
  'name': 'CrWinAsan(dll)',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['cr_win_clang_asan_shared']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_chromium_win_clang_asan_shared_tester = {
  'name': 'CrWinAsan(dll) tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_linux = {
  'name': 'ClangToTLinux',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['clang_tot_linux']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_linux_tester = {
  'name': 'ClangToTLinux tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_linux_dbg = {
  'name': 'ClangToTLinux (dbg)',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_linux_asan = {
  'name': 'ClangToTLinuxASan',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['clang_tot_linux_asan']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_linux_asan_tester = {
  'name': 'ClangToTLinuxASan tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_android_asan = {
  'name': 'ClangToTAndroidASan',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_mac = {
  'name': 'ClangToTMac',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['clang_tot_mac']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_mac_tester = {
  'name': 'ClangToTMac tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_mac_dbg = {
  'name': 'ClangToTMac (dbg)',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_mac_asan = {
  'name': 'ClangToTMacASan',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['clang_tot_mac_asan']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_mac_asan_tester = {
  'name': 'ClangToTMacASan tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': True,
}

b_clang_tot_ios = {
  'name': 'ClangToTiOS',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
    'ios/unified_builder_tester'
  ),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_clang_tot_win = {
  'name': 'ClangToTWin',
  'factory': m_annotator.BaseFactory('chromium', triggers=['clang_tot_win']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win_tester = {
  'name': 'ClangToTWin tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win_dbg = {
  'name': 'ClangToTWin(dbg)',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['clang_tot_win_dbg']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win_dbg_tester = {
  'name': 'ClangToTWin(dbg) tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win_dll = {
  'name': 'ClangToTWin(dll)',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['clang_tot_win_dll']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win_dll_tester = {
  'name': 'ClangToTWin(dll) tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win64 = {
  'name': 'ClangToTWin64',
  'factory': m_annotator.BaseFactory('chromium', triggers=['clang_tot_win64']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win64_tester = {
  'name': 'ClangToTWin64 tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win64_dbg = {
  'name': 'ClangToTWin64(dbg)',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['clang_tot_win64_dbg']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win64_dbg_tester = {
  'name': 'ClangToTWin64(dbg) tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win64_dll = {
  'name': 'ClangToTWin64(dll)',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['clang_tot_win64_dll']),
  'category': 'clang tot',
  'auto_reboot': False,
}
b_clang_tot_win64_dll_tester = {
  'name': 'ClangToTWin64(dll) tester',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'clang tot',
  'auto_reboot': False,
}

b_chromium_win7_shared_vs2013_dbg = {
  'name': 'Cr Win VS2013 (dbg)',
  'factory': f_chromium_win_shared_2013_dbg,
  'category': 'ninja',
  'auto_reboot': False,
}

b_chromium_win7_shared_vs2013 = {
  'name': 'Cr Win VS2013',
  'factory': f_chromium_win_shared_2013,
  'category': 'ninja',
  'auto_reboot': False,
}

b_chromium_win_mini_installer = {
  'name': 'Chromium Win MiniInstaller Tests',
  'factory': f_cr_win_rel_mini_installer,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_dbg_android_builder = {
  'name': 'Android Builder (dbg)',
  'factory': m_annotator.BaseFactory(recipe='chromium',
                                     triggers=['android_dbg']),
  'category': 'android',
}

b_chromium_dbg_android_mips_builder = {
  'name': 'Android MIPS Builder (dbg)',
  'factory': f_chromium_dbg_android_mips_builder,
  'category': 'android',
}

b_chromium_dbg_android_x86_builder = {
  'name': 'Android x86 Builder (dbg)',
  'factory': f_chromium_dbg_android_x86_builder,
  'category': 'android',
}

b_chromium_rel_android_user_builder_tests = {
  'name': 'Android User Builder Tests',
  'factory': f_chromium_rel_android_builder_tests,
  'category': 'android',
}

b_chromium_dbg_android_tests_jb_gn = {
  'name': 'Android Tests (JB GalaxyNexus)(dbg)',
  'factory': f_chromium_dbg_android_tests('jb-gn'),
  'category': 'android',
}

b_chromium_rel_android_remoting_tests = {
  'name': 'Android Remoting Tests',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='chromium'),
  'category': 'android',
}

b_chromium_dbg_android_tests_jb_nexus7 = {
  'name': 'Android Tests (JB Nexus7)(dbg)',
  'factory': f_chromium_dbg_android_tests('jb-n7'),
  'category': 'android',
}

b_chromium_dbg_android_tests_l_n5_user = {
  'name': 'Android Tests (L Nexus5)(dbg)',
  'factory': m_annotator.BaseFactory(recipe='chromium'),
  'category': 'android',
}

b_chromium_dbg_android_tests_k_n5_user = {
  'name': 'Android Tests (trial)(dbg)',
  'factory': m_annotator.BaseFactory(recipe='chromium'),
  'category': 'android',
}

b_chromium_dbg_android_tests_amp = {
  'name': 'Android Tests (amp)(dbg)',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      'android/appurify'),
  'category': 'android',
}

b_chromium_dbg_android_chromedriver_tests = {
  'name': 'Android ChromeDriver Tests (dbg)',
  'factory': f_chromium_dbg_android_chromedriver_tests,
  'category': 'android',
}

b_chromium_dbg_android_asan_builder_tests = {
  'name': 'Android Asan Builder Tests (dbg)',
  'factory': f_chromium_dbg_android_asan_builder_tests,
  'category': 'android',
}

b_chromium_dbg_android_shared_jb_nexus7 = {
  'name': 'Android Builder Tests (JB Nexus7)(shared)',
  'factory': f_chromium_dbg_android_shared,
  'category': 'android'
}

b_chromium_dbg_android_aosp_builder = {
  'name': 'Android AOSP Builder (dbg)',
  'factory': f_chromium_dbg_android_aosp_builder,
  'category': 'android',
}

b_chromium_dbg_ios_simulator = {
  'name': 'Chromium_iOS_Simulator_(dbg)',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
    'ios/unified_builder_tester'
  ),
  'category': 'ios',
  'auto_reboot': False,
}

b_chromium_rel_ios_device = {
  'name': 'Chromium_iOS_Device',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
    'ios/unified_builder_tester'
  ),
  'category': 'ios',
  'auto_reboot': False,
}

b_chromium_rel_ninja_ios_device = {
  'name': 'Chromium_iOS_Device_(ninja)',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
    'ios/unified_builder_tester'
  ),
  'category': 'ios',
  'auto_reboot': False,
}

b_chromium_linux_goma_canary = {
  'name': 'Chromium Linux Goma Canary',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_linux_goma_canary_clobber = {
  'name': 'Chromium Linux Goma Canary (clobber)',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_linux_precise_goma_linktest = {
  'name': 'Chromium Linux Precise Goma LinkTest',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_linux32_goma_canary_clobber = {
  'name': 'Chromium Linux32 Goma Canary (clobber)',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_mac_106_goma_canary = {
  'name': 'Chromium Mac 10.6 Goma Canary',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_mac_107_goma_canary = {
  'name': 'Chromium Mac 10.7 Goma Canary',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_mac_106_goma_canary_clobber = {
  'name': 'Chromium Mac 10.6 Goma Canary (clobber)',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_mac_107_goma_canary_clobber = {
  'name': 'Chromium Mac 10.7 Goma Canary (clobber)',
  'factory': m_annotator.BaseFactory('chromium'),
  'category': 'goma',
  'auto_reboot': True,
}

b_chromium_mac_1010 = {
  'name': 'Chromium Mac 10.10',
  'factory': f_chromium_mac_1010,
  'auto_reboot': False,
}

b_windows_8_app_certification = {
  'name': 'Windows 8 App Certification',
  'factory': f_windows_8_app_certification,
  'category': 'windows',
}

b_linux_arm = {
  'name': 'Linux ARM',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory('chromium'),
  'category': 'linux',
  'auto_reboot': False,
}

b_linux_arm_cross_compile = {
  'name': 'Linux ARM Cross-Compile',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      'chromium',
      {'use_mirror': ActiveMaster.is_production_host or None},
      triggers=['chromium_linux_arm']),
  'category': 'linux',
  'auto_reboot': False,
}

b_linux_arm_tests_panda = {
  'name': 'Linux ARM Tests (Panda)',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      'chromium_isolate'),
  'category': 'linux',
  'auto_reboot': False,
}

b_chromiumos_linux_tests = {
  'name': 'ChromiumOS Linux Tests',
  'factory': f_chromiumos_linux_tests,
  'category': 'linux',
  'auto_reboot': False,
}

b_chromium_ozone_tests = {
    'name': 'Ozone ECS Linux',
    'builddir': 'ozone-linux',
    'factory': annotator_factory.AnnotatorFactory().BaseFactory('ozone_ecs',
        {'use_mirror': ActiveMaster.is_production_host or None}),
    'auto_reboot': False,
}

b_chromium_trusty = {
    'name': 'Linux Trusty',
    'factory': annotator_factory.AnnotatorFactory().BaseFactory('chromium'),
    'category': 'linux',
    'auto_reboot': True,
}

b_chromium_trusty32 = {
    'name': 'Linux Trusty (32)',
    'factory': annotator_factory.AnnotatorFactory().BaseFactory('chromium'),
    'category': 'linux',
    'auto_reboot': True,
}

b_chromium_trusty_dbg = {
    'name': 'Linux Trusty (dbg)',
    'factory': annotator_factory.AnnotatorFactory().BaseFactory('chromium'),
    'category': 'linux',
    'auto_reboot': True,
}

b_chromium_trusty32_dbg = {
    'name': 'Linux Trusty (dbg)(32)',
    'factory': annotator_factory.AnnotatorFactory().BaseFactory('chromium'),
    'category': 'linux',
    'auto_reboot': True,
}

b_chromium_windows_drmemory_builder = {
  'name': 'Windows Builder (DrMemory)',
  'builddir': 'drm-cr',
  'factory': f_chromium_windows_drmemory_builder,
  'category': 'drmemory',
  'auto_reboot': False,
}

b_chromium_rel_win_drmemory_xp = {
  'name': 'Windows Tests (DrMemory XP)',
  'builddir': 'chromium-dbg-win-drmemory-xp',
  'factory': f_chromium_rel_win_drmemory,
  'category': 'drmemory|memory_tester',
  'auto_reboot': False,
}

b_chromium_tests_drmemory = {
  'name': 'Windows Tests (DrMemory)',
  'builddir': 'windows-tests-drm',
  'factory': f_chromium_rel_win_tests_drmemory,
  'category': 'drmemory',
  'auto_reboot': True,
}

b_chromium_windows_drmemory_64_builder = {
  'name': 'Windows Builder (DrMemory x64)',
  'builddir': 'drm-cr-64',
  'factory': f_chromium_windows_drmemory_64_builder,
  'category': 'drmemory',
  'auto_reboot': False,
}

b_chromium_tests_drmemory_64 = {
  'name': 'Windows Tests (DrMemory x64)',
  'builddir': 'windows-tests-drm-64',
  'factory': f_chromium_rel_win_tests_drmemory_64,
  'category': 'drmemory',
  'auto_reboot': True,
}

b_chromium_android_x64_builder = {
  'name': 'Android x64 Builder (dbg)',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='android/builder'),
  'category': 'android',
}

b_chromium_android_cronet_builder = {
  'name': 'Android Cronet Builder',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='cronet', triggers=['cronet_rel']),
  'category': 'android',
}

b_chromium_android_cronet_armv6_builder = {
  'name': 'Android Cronet ARMv6 Builder',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='cronet'),
  'category': 'android',
}

b_chromium_android_cronet_arm64_builder = {
  'name': 'Android Cronet ARM64 Builder',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='cronet'),
  'category': 'android',
}

b_chromium_android_cronet_x86_builder = {
  'name': 'Android Cronet x86 Builder',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='cronet'),
  'category': 'android',
}

b_chromium_android_cronet_mips_builder = {
  'name': 'Android Cronet MIPS Builder',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='cronet'),
  'category': 'android',
}

b_chromium_android_cronet_builder_dbg = {
  'name': 'Android Cronet Builder (dbg)',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='cronet'),
  'category': 'android',
}

b_chromium_android_cronet_arm64_builder_dbg = {
  'name': 'Android Cronet ARM64 Builder (dbg)',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='cronet'),
  'category': 'android',
}

b_chromium_android_cronet_x86_builder_dbg = {
  'name': 'Android Cronet x86 Builder (dbg)',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='cronet'),
  'category': 'android',
}

b_chromium_print_preview_linux = {
    'name': 'Print Preview Linux',
    'factory': annotator_factory.AnnotatorFactory().BaseFactory('chromium'),
    'category': 'print_preview',
    'auto_reboot': True,
}

b_chromium_print_preview_mac = {
    'name': 'Print Preview Mac',
    'factory': annotator_factory.AnnotatorFactory().BaseFactory('chromium'),
    'category': 'print_preview',
    'auto_reboot': True,
}

b_chromium_print_preview_win = {
    'name': 'Print Preview Win',
    'factory': annotator_factory.AnnotatorFactory().BaseFactory('chromium'),
    'category': 'print_preview',
    'auto_reboot': True,
}

b_chromium_openssl_mac = {
  'name': 'Mac OpenSSL',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory('chromium'),
  'category': 'openssl',
  'auto_reboot': True,
}

b_chromium_site_isolation_linux = {
  'name': 'Site Isolation Linux',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory('chromium'),
  'category': 'site_isolation',
  'auto_reboot': True,
}

b_chromium_site_isolation_win = {
  'name': 'Site Isolation Win',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory('chromium'),
  'category': 'site_isolation',
  'auto_reboot': True,
}

b_chromium_browser_side_navigation_linux = {
  'name': 'Browser Side Navigation Linux',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory('chromium'),
  'category': 'site_isolation',
  'auto_reboot': True,
}

b_chromium_closure_compilation_linux = {
  'name': 'Closure Compilation Linux',
  'factory': annotator_factory.AnnotatorFactory().BaseFactory(
      recipe='closure_compilation'),
  'category': 'closure_compilation',
  'auto_reboot': True,
}

b_chromium_cfi_linux = {
  'name': 'CFI Linux',
  'factory': m_annotator.BaseFactory('chromium',
                                     triggers=['chromium_cfi'],
                                     timeout=7200),
  'category': 'chromium_cfi',
  'auto_reboot': True,
}

def windows_browser_drmemory_light_tester(shard, total):
  if shard < 1 or shard > total:
    raise
  ret = {'category': 'drmemory'}
  ret['name'] = 'Windows Browser (DrMemory light) (%d)' % shard
  ret['builddir'] = 'windows-browser-drm-light-%d' % shard
  ret['factory'] = win_out().ChromiumFactory(
      target='Release',
      slave_type='Tester',
      build_url=chromium_windows_drmemory_archive,
      tests=['drmemory_light_browser_tests_%d_of_%d' % (shard, total)],
      options=['browser_tests'],
      factory_properties={ 'halt_on_missing_build': True,
                           'retry_failed' : False })
  return ret

c['builders'] = [
  # Windows release
  b_chromium_rel_builder,
  b_chromium_rel_win8_tests_1,
  b_chromium_rel_win8_tests_2,
  b_chromium_win_goma,
  b_chromium_win_goma_shared,
  b_chromium_win7_goma,
  b_chromium_win7_goma_shared,
  b_chromium_win7_goma_dbg,
  b_chromium_win7_goma_clobber,
  b_chromium_win7_shared_vs2013_dbg,
  b_chromium_win7_shared_vs2013,
  b_chromium_win_clang_goma,
  b_windows_8_app_certification,
  b_chromium_win_x64,
  b_chromium_win_clang,
  b_chromium_win_clang_tester,
  b_chromium_win_clang_dbg,
  b_chromium_win_clang_dbg_tester,
  b_chromium_win_clang_shared,
  b_chromium_win_clang_shared_tester,
  b_chromium_win_clang_64,
  b_chromium_win_clang_64_tester,
  b_chromium_win_clang_64_dbg,
  b_chromium_win_clang_64_dbg_tester,
  b_chromium_win_clang_64_shared,
  b_chromium_win_clang_64_shared_tester,
  b_chromium_win_pgo_builder,
  b_chromium_win_x64_pgo_builder,

  # Windows debug
  b_chromium_dbg_builder,
  b_chromium_dbg_vista_tests_1,
  b_chromium_dbg_vista_tests_2,

  # Mac BuilderTesters
  b_chromium_mac_106_goma_canary,
  b_chromium_mac_107_goma_canary,
  b_chromium_mac_106_goma_canary_clobber,
  b_chromium_mac_107_goma_canary_clobber,
  b_chromium_mac_1010,

  # Windows /Analyze builder
  b_chromium_win_analyze,

  # Instant Extended Testers
  b_chromium_win_instantextended,

  # Buildrunner Testers
  b_chromium_lin_buildrunner,
  b_chromium_win_buildrunner,
  b_chromium_mac_buildrunner,
  b_chromium_mac_10_8_buildrunner,
  b_chromium_mac_10_9_buildrunner,

  # Linux BuilderTesters
  b_chromium_linux_goma_canary,
  b_chromium_linux_goma_canary_clobber,
  b_chromium_linux_precise_goma_linktest,
  b_chromium_linux32_goma_canary_clobber,
  b_chromiumos_linux_tests,

  # Linux ARM
  b_linux_arm,
  b_linux_arm_cross_compile,
  b_linux_arm_tests_panda,

  # Android
  b_chromium_dbg_android_builder,
  b_chromium_dbg_android_mips_builder,
  b_chromium_dbg_android_x86_builder,
  b_chromium_dbg_android_tests_jb_gn,
  b_chromium_dbg_android_tests_jb_nexus7,
  b_chromium_dbg_android_tests_l_n5_user,
  b_chromium_dbg_android_tests_k_n5_user,
  b_chromium_dbg_android_tests_amp,
  b_chromium_rel_android_remoting_tests,

  b_chromium_rel_android_user_builder_tests,
  b_chromium_dbg_android_chromedriver_tests,
  b_chromium_dbg_android_asan_builder_tests,
  b_chromium_dbg_android_shared_jb_nexus7,
  b_chromium_android_x64_builder,

  # Android AOSP
  b_chromium_dbg_android_aosp_builder,

  # Cronet
  b_chromium_android_cronet_builder,
  b_chromium_android_cronet_armv6_builder,
  b_chromium_android_cronet_arm64_builder,
  b_chromium_android_cronet_x86_builder,
  b_chromium_android_cronet_mips_builder,
  b_chromium_android_cronet_builder_dbg,
  b_chromium_android_cronet_arm64_builder_dbg,
  b_chromium_android_cronet_x86_builder_dbg,

  # iOS
  b_chromium_dbg_ios_simulator,
  b_chromium_rel_ios_device,
  b_chromium_rel_ninja_ios_device,

  # Sanitizers
  b_blink_linux_lsan_asan,

  # NaCl
  b_chromium_rel_win32_morenacl,
  b_chromium_rel_win64_morenacl,
  b_chromium_rel_mac_morenacl,
  b_chromium_rel_linux_morenacl,

  # MiniInstaller
  b_chromium_win_mini_installer,

  # Ozone Shell
  b_chromium_ozone_tests,

  # Ubuntu 14.04 Trusty
  b_chromium_trusty,
  b_chromium_trusty32,
  b_chromium_trusty_dbg,
  b_chromium_trusty32_dbg,

  # Print Preview
  b_chromium_print_preview_linux,
  b_chromium_print_preview_mac,
  b_chromium_print_preview_win,

  # OpenSSL
  b_chromium_openssl_mac,

  # Site Isolation
  b_chromium_site_isolation_linux,
  b_chromium_site_isolation_win,
  b_chromium_browser_side_navigation_linux,

  # Closure Compilation
  b_chromium_closure_compilation_linux,

  # Blink repo transition practice bots.
  b_linux_practice,
  b_linux_practice_tester,

  # Clang ToT bots.
  b_clang_tot_linux,
  b_clang_tot_linux_tester,
  b_clang_tot_linux_dbg,
  b_clang_tot_linux_asan,
  b_clang_tot_linux_asan_tester,
  b_clang_tot_android_asan,
  b_clang_tot_mac,
  b_clang_tot_mac_tester,
  b_clang_tot_mac_dbg,
  b_clang_tot_mac_asan,
  b_clang_tot_mac_asan_tester,
  b_clang_tot_ios,
  b_clang_tot_win,
  b_clang_tot_win_tester,
  b_clang_tot_win_dbg,
  b_clang_tot_win_dbg_tester,
  b_clang_tot_win_dll,
  b_clang_tot_win_dll_tester,
  b_clang_tot_win64,
  b_clang_tot_win64_tester,
  b_clang_tot_win64_dbg,
  b_clang_tot_win64_dbg_tester,
  b_clang_tot_win64_dll,
  b_clang_tot_win64_dll_tester,
  b_chromium_win_clang_lld,
  b_chromium_win_clang_lld_tester,
  b_chromium_win_clang_asan,
  b_chromium_win_clang_asan_tester,
  b_chromium_win_clang_asan_shared,
  b_chromium_win_clang_asan_shared_tester,

  # Control flow integrity.
  b_chromium_cfi_linux,
]

# DrMemory test bots
b_win_drmemory = [
  b_chromium_windows_drmemory_builder,
  b_chromium_rel_win_drmemory_xp,
  b_chromium_tests_drmemory,
  b_chromium_windows_drmemory_64_builder,
  b_chromium_tests_drmemory_64,
]

# Windows Browser (DrMemory light)
for i in range(WINDOWS_BROWSER_DRMEMORY_LIGHT_TESTERS):
  c['builders'].append(
      windows_browser_drmemory_light_tester(
          i + 1, WINDOWS_BROWSER_DRMEMORY_LIGHT_TESTERS))

c['builders'].extend(b_win_drmemory)

master_win_drmemory_cfg.Update(config, ActiveMaster, c)

# Associate the slaves to the manual builders. The configuration is in
# slaves.cfg.
slaves = slaves_list.SlavesList('slaves.cfg', 'ChromiumFYI')
for builder in c['builders']:
  builder['slavenames'] = slaves.GetSlavesName(builder=builder['name'])


####### BUILDSLAVES

# The 'slaves' list defines the set of allowable buildslaves. List all the
# slaves registered to a builder. Remove dupes.
c['slaves'] = master_utils.AutoSetupSlaves(c['builders'],
                                           config.Master.GetBotPassword())

# Make sure everything works together.
master_utils.VerifySetup(c, slaves)


####### STATUS TARGETS

# Buildbot master url:
# Must come before AutoSetupMaster().
c['buildbotURL'] = ActiveMaster.buildbot_url

# Adds common status and tools to this master.
master_utils.AutoSetupMaster(
    c, ActiveMaster,
    public_html="../master.chromium/public_html",
    templates=['../master.chromium/templates'],
    enable_http_status_push=ActiveMaster.is_production_host,
    order_console_by_time=True)

# Add more.

if STATUS_PUSH:
  from buildbot.status.status_push import HttpStatusPush
  c['status'].append(HttpStatusPush(
      'http://craebuild.appspot.com/status-listener'))

if DRMEMORY_NOTIFIER:
  categories_steps = {
    'memory_tester': [
      'memory test: gcm_unit_tests',
      'memory test: printing',
      'memory test: media',
      'memory test: remoting',
      'memory test: sql',
      'memory test: sync',
      'memory test: sync_unit_tests',
      'memory test: ipc_tests',
      'memory test: base_unittests',
      'memory test: content',
      'memory test: crypto',
      'memory test: net',
      'memory test: ui_base_unittests',
      'memory test: unit',  # unit_tests can be sharded
      'memory test: unit_1',
      'memory test: unit_2',
      'memory test: url_unittests',
   ],
  }
  c['status'].append(failures_notifier.FailuresNotifier(
      fromaddr=ActiveMaster.from_address,
      categories_steps=categories_steps,
      exclusions={},
      relayhost=config.Master.smtp,
      status_header='New DrMemory failure on "%(builder)s":\n%(steps)s',
      subject='drmemory buildbot %(result)s in %(projectName)s on '
              '%(builder)s, revision %(revision)s',
      sendToInterestedUsers=False,  # don't send e-mails to the committers.
      extraRecipients=[
          'bruening+drmfyifailure@google.com',
          'zhaoqin+drmfyifailure@google.com',
      ],
      lookup=master_utils.FilterDomain(),
      forgiving_steps=[],
      use_getname=True))

c['status'].append(MailNotifier(
      fromaddr='ukai@chromium.org',  # Reply-To address
      mode='failing',
      categories=['goma'],
      relayhost=config.Master.smtp,
      subject='goma canary buildbot %(result)s in %(projectName)s '
              'on %(builder)s',
      extraRecipients=['goma+alert@google.com'],
      sendToInterestedUsers=False))

c['status'].append(MailNotifier(
      fromaddr=ActiveMaster.from_address,  # Reply-To address
      mode='problem',
      relayhost=config.Master.smtp,
      subject='Cronet build failed on %(builder)s',
      extraRecipients=['cronet-team+buildproblem@google.com'],
      sendToInterestedUsers=False,
      builders=['Android Cronet Builder', 'Android Cronet Builder (dbg)']))

c['status'].append(MailNotifier(
      fromaddr=ActiveMaster.from_address,  # Reply-To address
      mode='failing',
      relayhost=config.Master.smtp,
      subject='Build failure on %(builder)s',
      extraRecipients=[
        'sebmarchand+pgofailure@google.com',
        'scottmg+pgofailure@google.com'
      ],
      sendToInterestedUsers=False,
      builders=['Chromium Win PGO Builder']))

c['status'].append(MailNotifier(
      fromaddr=ActiveMaster.from_address,  # Reply-To address
      mode='failing',
      relayhost=config.Master.smtp,
      subject='Remoting Android Tests failing on %(builder)s',
      extraRecipients=[
        'remoting-android-test-results@google.com',
      ],
      sendToInterestedUsers=False,
      builders=['Android Remoting Tests']))
